#include <stdio.h>
int main(void)
{
    printf("Tis program creates a magic square of a specified size.\n");
    printf("The size must be an odd number between 1 and 99.\n");
    printf("Enter size of magic square: ");
    int size;
    scanf("%d", &size);
    int square[size][size];
    for (int i = 0; i < size; i ++) {
        for (int j = 0; j < size; j++)
            square[i][j] = -1;
    }

    int row = 0, column = size / 2;
    for (int i = 1; i <= size * size; i++) {
        square[row][column] = i;
        row = (row + size - 1) % size;
        column = (column + 1) % size;
        if (square[row][column] >= 0) {
            row = (row + 2) % size;
            column = (column + size - 1) % size;
        }
    }

    for (int i = 0; i < size; i ++) {
        for (int j = 0; j < size; j++) {
            printf("%5d", square[i][j]);
        }
        printf("\n");
    }
    return 0;
}